package dmir.reaction.publico.mysql;

import java.sql.Connection;
import java.sql.DriverManager;

public class MySQLConnection {
		
	public static Connection getConnection(String username, String password, String url) throws Exception {	
		
		Connection connect = null;
		
		try {
			
			// This will load the MySQL driver, each DB has its own driver
			Class.forName("com.mysql.jdbc.Driver");
			url = "jdbc:mysql://borat/publico";

			// Setup the connection with the DB
			try {
				
				System.out.println("Connecting MySQL...");
				connect = DriverManager.getConnection(url, username, password);				
				System.out.println(connect.toString());
								
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println(e.getMessage());
				System.exit(0);
			}
		}
		
		catch (Exception e) {
			// TODO: handle exception
			System.out.println(e);
			e.printStackTrace();
		}
		
		return connect;
	}
}
